home *** CD-ROM | disk | FTP | other *** search
- 1910562448
- # A QUICK TOUR OF MAPLE V
- # Copyright (c) 1991 by Waterloo Maple Software
-
- # Maple is an essential tool for anyone who needs to use or study
- # mathematics. In the next few screens you will get a glimpse of a few of
- # the over 2000 Maple functions and what they can do for you. While this
- # Maple Demonstration runs only on an 80386 or 80486 based machine, all
- # the Maple commands appearing in this Tour are part of Maple on all
- # other platforms including the Macintosh and Unix systems. Only the user
- # interface varies from platform to platform.
-
- # This demonstration consists of a sequence of descriptive paragraphs
- # and Maple commands (which appear after a prompt character). When a
- # command appears, press Enter to execute it and display the answer.
- # For example, press Enter now:
-
- 1 + 2;
- # Maple is capable of a wide variety of numeric, graphic, and symbolic
- # operations. Maple normally does rational arithmetic. Expressions are
- # entered using a syntax similar to that of common programming languages
- # such as BASIC, FORTRAN, or Pascal.
-
-
- # NUMERIC CALCULATIONS
-
- # To use Maple as a sophisticated calculator, simply enter the
- # calculation you wish to perform on one or more lines. Some of the
- # operators available are: + add, - subtract, * multiply, / divide, ^
- # exponentiate, and sqrt() square root. For example:
-
- 32 * 12^4;
- # Maple recognizes a wide variety of special operators including
- # factorial, greatest common divisor, least common multiple, modular
- # arithmetic, and so on:
-
- 20! - 12!;
- # The most recent result (2432902007697638400) can be easily included in
- # any subsequent calculation without having to type it. The double-quote
- # character (") is used to refer to the last expression computed by
- # Maple, in a manner analogous to the use of ditto marks in ordinary
- # English. For example, this integer can be separated into its prime
- # factors:
-
- ifactor(");
- # This result can be checked by multiplying it out:
-
- expand(");
- # Maple's normal mode of computation is exact arithmetic, in which there
- # can be no roundoff or truncation errors:
-
- (2^30 / 3^20) * sqrt(2);
- # But Maple can also provide an approximation in the form of a decimal
- # floating point value:
-
- evalf(");
- # Maple is capable of finding both finite and infinite sums:
-
- sum((1+i)/(1+i^4),i=1..20);
- # and Maple can do floating-point arithmetic to any desired precision:
-
- evalf(",30);
- # Maple can do complex arithmetic:
-
- evalc((3+5*I)*(7+4*I));
- # and compute numeric values for the elementary functions and many
- # special functions and constants:
-
- evalf(exp(1.0));
- evalf(GAMMA(2.5));
- evalf(Pi,40);
-
- # 2-DIMENSIONAL AND 3-DIMENSIONAL GRAPHICS
-
- # Maple supports both 2-dimensional and 3-dimensional graphics. The
- # demonstration version supports only EGA or VGA display adapters. The
- # full version also supports AT&T, CGA, Hercules, and MCGA displays, and
- # EPSON, HP, IBM, Toshiba, and POSTSCRIPT printers.
-
- # The Maple plot() command provides support for two-dimensional graphs of
- # one or more functions specified as expressions, procedures, parametric
- # functions, or lists of points. For example, the following shows the sum
- # of two sine curves. Press the Escape key when you are finished viewing
- # the plot.
-
- plot(sin(x)+sin(5*x),x=-1..4);
-
- # The plot3d() command can plot functions of two variables, as well as
- # parametric curves or surfaces. The following example plots a simple
- # function of two variables:
-
- # Once the plot is displayed, you can press the F10 key to display a menu
- # that lets you manipulate the plot in various ways. For example,
- # pressing F10 to display the menu, followed by V to invoke the View
- # item, will let you rotate the plot. After rotating to the desired
- # orientation (using the arrow keys), press Escape (to return to the menu),
- # and then D to redraw the plot in the new orientation. Other
- # manipulations you can perform include adding axes, changing the color
- # scheme, changing perspective, and adding a title. The full version also
- # lets you create a printed copy of the graph (about 10 different types
- # of printers and plotters are supported), or save an image of the graph
- # in a file for importing into other programs. Press the Escape key when
- # you are finished viewing the plot.
-
- plot3d(sin(x)+sin(5*y),x=-1..4,y=-1..4);
-
- # Maple also provides a package of functions to generate more complex
- # plots easily. This package is called plots, and is loaded using the
- # with() command. The package includes functions for plotting in
- # spherical and cylindrical coordinates, plotting matrices and complex
- # functions, points in space, and many other specialized graphical
- # representations. One function in this package (included in the Maple
- # Demonstration) is tubeplot(), which plots a parametric curve through
- # space, with the thickness of the curve defined by a constant or
- # expression. For example (be sure to press the Enter key at the end of
- # each line):
-
- with(plots):
- tubeplot([-10*cos(t)-2*cos(5*t)+15*sin(2*t),
- -15*cos(2*t)+10*sin(t)-2*sin(5*t),
- 10*cos(3*t)], t=0..2*Pi, radius=3*cos(t*Pi/3));
-
-
- # ALGEBRAIC OPERATIONS
-
- # Maple is most powerful when working as a symbolic or algebraic
- # calculator. First, an expression is entered, and then Maple echoes:
-
- (x+y)^3*(x+y)^2;
- # In the next four steps the expression is multiplied out, cubed,
- # expanded a second time and finally factored:
-
- expand(");
- "^3;
- expand(");
- factor(");
- # Maple provides a basic form of simplification for those expressions
- # that lie in the domain of rational functions. The result is expressed
- # in the form p/q with the common factors cancelled:
-
- normal((x^3-y^3)/(x^2+x-y-y^2));
- # More complex simplifications can be accomplished using the simplify()
- # command. By using the numer() and denom() commands you can even operate
- # on portions of an expression.
-
- # In some cases it is useful to define an expression so that it can be
- # referred to later. Here e1 is set equal to the quotient of the
- # expansion of two expressions. e1 is then simplified:
-
- e1 := expand((41*x^2+x+1)^2*(2*x-1)) / expand((3*x+5)*(2*x-1));
- normal(e1);
- # The convert() operation allows you to convert many types of expressions
- # into specific forms. The following example converts an expression into
- # a partial fraction:
-
- (3*x+5) / (x^2-3*x+2);
- convert(",parfrac,x);
- # Using the Maple proc() function allows for the definition of
- # functions:
-
- f1:= proc(x) x^2 end;
- # Numeric or symbolic values of the function can be obtained:
-
- f1(2);
- f1(a+b);
- # Functions of several variables or functions that contain more than one
- # rule can be defined:
-
- f2:= proc(x) if x > 3 then x^2 else if x <= 3 then x-5 fi fi end;
- f2(0);
-
- # SOLVING EQUATIONS AND SYSTEMS OF EQUATIONS
-
- # You can use Maple to solve algebraic equations (or expressions assumed
- # to be equal to zero):
-
- x^3-1/2*x^2*a+13/3*x^2-13/6*x*a-10/3*x+5/3*a;
- solve(",x);
- # Maple can also solve systems of equations:
-
- eqn1 := x + 2*y + 3*z + 4*t + 5*u = 6;
- eqn2 := 5*x + 5*y + 4*z + 3*t + 2*u = 1;
- eqn3 := 3*y + 4*z - 8*t + 2*u = 1;
- eqn4 := x + y + z + t + u = 9;
- eqn5 := 8*x + 4*z + 3*t + 2*u = 1;
- solutions1 := solve({eqn.(1..5)}, {x,y,z,t,u});
- # You can also choose to solve an under-constrained set of equations:
-
- solutions2 := solve({eqn.(1..4)}, {x,y,z,t,u});
- # Since exact symbolic arithmetic is performed, Maple can recognize
- # equations that are linearly dependent. The set of under-constrained
- # equations (eqn1 ... eqn4) produces a set of solutions in which the
- # equation t = t appears. This means that t can take arbitrary values.
-
- # We can check the solutions produced by substituting the values given
- # for x, y, z, t, and u into the original set of of equations.
- # This set of invariants confirms the validity of the answer that was
- # computed by the solve command:
-
- subs(solutions2,{eqn.(1..4)});
-
- # CALCULUS
-
- # Maple is an outstanding tool for working with calculus. You will be
- # able to compute limits as well as integrate and differentiate:
-
- f := (x^2-2*x+1)/(x^4+3*x^3-7*x^2+x+2);
- limit(f,x=1);
- f := (2*x+3)/(7*x+5);
- limit(f,x=infinity);
- f := x*sin(x) + 2*x^2;
- diff(f,x);
- int(",x);
- # A wide variety of examples showing the use of Maple in the study of
- # calculus can be found in Maple for the Calculus Student, A Tutorial by
- # Wade Ellis and Ed Lodi. This inexpensive supplement is available from
- # Brooks/Cole. The following example is from Maple for the Calculus
- # Student:
-
- # Maple can solve many differential equations as explicit
- # functions (in closed form). When necessary, it can give
- # approximate numerical solutions to such equations. In addition,
- # Maple provides a Laplace transform capability that can be used
- # in solving differential equations.
-
- # Maple can easily solve the differential equation y' = y:
-
- dsolve(diff(y(x),x) - y(x) = 0, y(x));
-
- # MATRIX OPERATIONS
-
- # Maple comes with a wide variety of special packages. Among these is the
- # Linear Algebra Package. This package has a complete set of commands for
- # working in linear algebra and other areas that involve matrices,
- # arrays, and determinants. Loading the Linear Algebra Package is
- # accomplished as follows:
-
- with(linalg):
-
- # Once the package is resident, many additional commands are available
- # (only a few of them are available in the Demonstration). Here we define
- # a 2-by-2 symbolic array:
-
- M := array(1...2,1...2);
- # Then find its determinant:
-
- det(M);
- # Next, let Maple define a special matrix, find the inverse of that
- # matrix, and finally multiply those matrices together to obtain the
- # identity matrix as a check:
-
- H := hilbert(5);
- H1 := inverse(H);
- multiply(H,H1);
- # In the following three commands, Maple will generate a 3-by-3 matrix
- # that has some symbolic entries, take its determinant, and finally
- # factor that determinant:
-
- V := vandermonde([u,v,w]);
- d := det(V);
- factor(d);
-
- # ON-LINE HELP
-
- # Maple contains a complete on line help system. The following command
- # will display an index of Maple command categories (when you are done
- # looking at the help file, press the Escape key):
-
- ?index
-
- # The ? command invokes the help browser to display information about the
- # selected topic. Users of older versions of Maple will be interested in
- # knowing that the ? command does not require reserved words, symbols, or
- # assigned names to be quoted, as the help() procedure requires.
-
- # When the browser is displaying information about a topic, you can
- # browse through this information using the cursor movement keys. Lines
- # containing Maple statements can be selected, and pasted into your Maple
- # session and executed. The full version of Maple also lets you edit
- # these lines before pasting them into the session.
-
- # The help system includes the complete definition of syntax and
- # description of function, as well as examples. Here are two more
- # examples of on-line help (remember to press Escape when you are done
- # with each one):
-
- ?ifactor
- ?plot3d
-
- # If you do not know the topic you wish to read about, pressing F1 during
- # your Maple session will display a hierarchy of topics from which you can
- # select. The demonstration version supports this feature, but the
- # information for all but three of the topics is not included on the
- # demonstration diskette. Try pressing F1 now.
-
- # ------------------------------------------------------------------------
- # For more information, or to order, contact:
-
- # Brooks/Cole Publishing Company
- # 511 Forest Lodge Road
- # Pacific Grove, CA 93950
-
- # To order: (800) 354-9706
- # Information and Support: (408) 373-0728
- # Fax: (408) 375-6414
-
- # E-mail: brooks.cole@applelink.apple.com
- # ------------------------------------------------------------------------
-
- # You can now try some more Maple commands (you can recall and edit earlier
- # commands using the arrow keys), or press F3 to return to DOS.
-